home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6756 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  45 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!milyng
  3. From: mikael@pobox.com (Mikael Lyngvig)
  4. Subject: Re: Calling exe's within main?
  5. Message-ID: <milyngDMnM99.Fwv@netcom.com>
  6. Sender: milyng@netcom15.netcom.com
  7. Organization: Hacker's Paradise, Inc.
  8. X-Newsreader: WinVN 0.99.7
  9. References: <4fj5e7$7tr@newnews.iafrica.com>
  10. Date: Mon, 12 Feb 1996 08:29:32 GMT
  11.  
  12. In article <4fj5e7$7tr@newnews.iafrica.com>, ashroff@iaccess.za says...
  13.  
  14. >I am trying to write a simple program that will connect a network drive, 
  15. >then run a specified application, and then disconnect that network drive.
  16. >
  17. >But, how do I do the following :
  18. >
  19. >call net use   // this is a network command
  20. >     app.exe   // this could be any application
  21. >
  22. >Any help would be greatly appreciated.
  23.  
  24. The simple way to do it would be to use system():
  25.  
  26. int main(int argc, const char *argv[])
  27. {
  28.    /* look in manual for system() return codes */
  29.  
  30.    system("net use");
  31.    system("app.exe");
  32.  
  33.    return 0;
  34. }
  35.  
  36. A bit more complicated (but usually faster), would be to use one of the 
  37. spawn() functiosns.  The hard way to do it, would be to use whatever OS you're 
  38. using's native method of executing programs.
  39.  
  40. You're sure a batch file isn't enough?
  41.  
  42.  
  43. Mikael
  44.  
  45.